<?php namespace Barryvdh\Debugbar\Twig\Extension;

use Barryvdh\Debugbar\Twig\TokenParser\StopwatchTokenParser;
use Illuminate\Foundation\Application;
use Twig_Extension;


class Stopwatch extends Twig_Extension
{
    
    protected $debugbar;

    
    public function __construct(Application $app)
    {
        if ($app->bound('debugbar')) {
            $this->debugbar = $app['debugbar'];
        } else {
            $this->debugbar = null;
        }
    }

    
    public function getName()
    {
        return 'stopwatch';
    }

    public function getTokenParsers()
    {
        return [
            
            new StopwatchTokenParser($this->debugbar !== null),
        ];
    }

    public function getDebugbar()
    {
        return $this->debugbar;
    }
}
